package com.zb.controller;



import com.zb.common.R;
import com.zb.dto.SetmealDto;
import com.zb.entity.PageData;
import com.zb.service.SetmealDishService;
import com.zb.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Autowired
    SetmealDishService setmealDishService;

    @Autowired
    SetmealService setmealService;


    //添加套餐
    @PostMapping
    public R<String> addSetmeal(@RequestBody SetmealDto setmealDto) {

        setmealService.addSetmeal(setmealDto);
        return R.success("", "新增套餐成功");
    }

    //分页查询套餐
    @GetMapping
    public R<PageData> getSetmealList(int page, int pageSize, String name) {

        PageData list =  setmealService.getSetmealList(page, pageSize, name);
        return R.success(list, "查询套餐成功");
    }

    //删除套餐
    @DeleteMapping
    public R<String> delSetmealByIds(@RequestParam List<Long> ids) throws Exception {
        setmealService.delSetmealByIds(ids);
        return R.success("", "删除成功");
    }
}
